import request from "../utils/request";

/**
 * 添加菜单
 */
export function addMenu(data) {
  return request({
    url: "/api/menu",
    method: "post",
    data: data,
  });
}

/**
 * 删除菜单
 */
export function deleteMenu(id) {
  return request({
    url: `/api/menu/${id}`,
    method: "delete",
  });
}

/**
 * 更新菜单
 */
export function updateMenu(data) {
  return request({
    url: "/api/menu",
    method: "put",
    data: data,
  });
}

/**
 * 菜单详情
 */
export function getMenu(id) {
  return request({
    url: `/api/menu/${id}`,
    method: "get",
  });
}

/**
 * 菜单列表
 */
export function listMenu(query) {
  return request({
    url: "/api/menu",
    method: "get",
    params: query,
  });
}

/**
 * 权限码列表
 */
export function listPermissions() {
  return request({
    url: "/api/menu/permissions",
    method: "get",
  });
}
